const path = require('path');
const resolve = require('path').resolve
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');

const config = {
  optimization: {
    minimizer: [new OptimizeCSSAssetsPlugin({})],
  },
  mode: 'production',
  // 入口
  entry: path.join(__dirname, './src/main.js'),
  // 出口
  output: {
    path: path.join(__dirname, './dist'),
    filename: 'bundle.js'
  },

  module: {
    rules: [
      {
        test: /\.less$/,
        loaders: [
          MiniCssExtractPlugin.loader,
          {
            loader: 'css-loader',
          },
          {
            loader: 'less-loader',
            options: {
              javascriptEnabled: true
            },
          },
        ]
      },
      // 处理字体
      {
        test: /\.(eot|svg|ttf|woff|woff2|otf)$/,
        use: [
          // "url-loader",
          {
            loader: 'file-loader',
            options: {
              name: './fonts/[name].[ext]'
            }
          }
        ]
      },
    ],
  },
  plugins: [
    new MiniCssExtractPlugin({
      filename: './iview.css',
    })
  ],
}

module.exports = config